SQL Data Types
Data Types:
In MySQL there are three main data types: string, numeric, and date and time.
String Data Types:
CHAR(size)- A FIXED length string (can contain letters, numbers, and special characters). The size parameter specifies the column length in characters - can be from 0 to 255. Default is 1
VARCHAR(size)- A VARIABLE length string (can contain letters, numbers, and special characters). The size parameter specifies the maximum column length in characters - can be from 0 to 65535
BINARY(size)- Equal to CHAR(), but stores binary byte strings
VARBINARY(size)- Equal to VARCHAR(), but stores binary byte strings.
Numeric Data Types:
BIT(size)- A bit-value type. The number of bits per value is specified in size. The size parameter can hold a value from 1 to 64. The default value for size is 1.
TINYINT(size)- A very small integer. Signed range is from -128 to 127. Unsigned range is from 0 to 255
SMALLINT(size)- A small integer. Signed range is from -32768 to 32767. Unsigned range is from 0 to 65535.
MEDIUMINT(size)- A medium integer. Signed range is from -8388608 to 8388607. Unsigned range is from 0 to 16777215.
INT(size)- A medium integer. Signed range is from -2147483648 to 2147483647. Unsigned range is from 0 to 4294967295.
INTEGER(size)- Equal to INT(size)
FLOAT(size, d)- A floating point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter.
DECIMAL(size, d)- An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter. The maximum number for size is 65. The maximum number for d is 30. The default value for size is 10. The default value for d is 0.